﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms;

namespace TA.Win.Utils.Design
{
	/// <summary>
	/// Base class for all property editors which utilize a Windows form.
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public abstract class BaseFormEditor<T> : UITypeEditor, IDisposable
		where T : Form, new()
	{

		#region PUBLIC
		#region INIT
		#endregion
		#region EVENTS
		#endregion
		#region PROPS
		/// <summary>
		/// Gets the form.
		/// </summary>
		public T Form
		{
			get
			{
				if (this._form == null)
				{
					this._form = new T();
					this._form.CreateControl();
				}
				return this._form;
			}
		}
		#endregion
		#region METHODS
		/// <summary>
		/// Returns Modal.
		/// </summary>
		/// <param name="context"></param>
		/// <returns></returns>
		public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
		{
			return UITypeEditorEditStyle.Modal;
		}
		/// <summary>
		/// Dispose.
		/// </summary>
		public void Dispose()
		{
			if (this._form != null)
			{
				this._form.Dispose();
			}
		}
		#endregion
		#endregion
		#region INTERNAL
		#region CONST/STATIC
		#endregion
		#region VARS
		T _form;
		#endregion
		#region PROPS
		#endregion
		#region METHODS
		#region INIT
		#endregion
		#region DATA
		#endregion
		#region HANDLERS
		#endregion
		#endregion
		#endregion

		#region IDisposable Members


		#endregion
	}
}
